# demo02_for_range.py
for i in range(5):  # range(5) -> range(0, 5, 1)
    print(i)
# range 和 for 连用
# 1. 控制循环的次数   5 hello world
for i in range(5):
    print("第", i+1, "次:", "hello world")
# 2. 作为序列的索引下标使用
list01 = ["zhangsan", "lisi", "ww", "zhaoliu"] # 0~3
for index in range(4):  # range(4): 0 1 2 3
    if index % 2 == 0:
        print(list01[index])
for index in range(0, 4, 2):  # 0 2
    print(list01[index])

# >>> range(1, 7)  # 1 2 3 4 5 6
# range(1, 7)
# >>> list(range(1, 7))
# [1, 2, 3, 4, 5, 6]
# >>> range(1, 11, 2)  # 1 2 3 4 5 6 7 8 9 10
# range(1, 11, 2)
# >>> list(range(1, 11, 2))
# [1, 3, 5, 7, 9]